"use strict";
const e = require("../../common/vendor.js"),
  a = require("../../api/MenuButton.js"),
  t = require("../../api/request.js"),
  n = require("../../store/index.js");
Math || (u + s)();
const u = () => "./components/recomment.js",
  s = () => "../Common-components/card-flow.js",
  r = {
    __name: "index",
    setup(u) {
      e.useCssVars((t => ({
        "1798167e": e.unref(a.MenuButton)().seViewHeight,
        faf1db54: T.value,
        "17ea92f5": e.unref(a.MenuButton)().top,
        "159adb87": e.unref(a.MenuButton)().height,
        "3537fb32": e.unref(a.MenuButton)().left
      })));
      const s = n.dataSet();
      let r = e.ref(!1);

      function o() {
        r.value = !0, e.wx$1.hideTabBar({
          animation: !0
        })
      }

      function l() {
        r.value = !1, e.wx$1.showTabBar({
          animation: !0
        })
      }
      e.watch(r, (a => {
        r.value ? e.wx$1.setPageStyle({
          style: {
            overflow: "hidden"
          }
        }) : e.wx$1.setPageStyle({
          style: {
            overflow: "inherit"
          }
        })
      }));
      const i = e.ref({}),
        c = e.ref(0),
        v = e.ref([{
          icon: "/static/icon/index/jieban.png",
          text: "结伴"
        }, {
          icon: "/static/icon/index/lvpai.png",
          text: "旅拍/跟拍"
        }, {
          icon: "/static/icon/index/zhibo.png",
          text: "直播"
        }, {
          icon: "/static/icon/index/yiriyou.png",
          text: "一日游"
        }, {
          icon: "/static/icon/index/minsu.png",
          text: "民宿/客栈"
        }]),
        d = e.ref([]),
        f = e.ref([]),
        p = e.ref([]),
        w = e.ref([]),
        g = e.ref([]),
        x = e.ref(0),
        y = e.ref(0),
        h = e.ref(0),
        m = e.ref([]),
        _ = e.ref("001");
      async function q(a) {
        const n = a.currentTarget.dataset.index;
        h.value = m.value[n].left - e.index.getSystemInfoSync().windowWidth / 2 + m.value[n].width / 2, y.value = n;
        const u = p.value[n].key;
        if (_.value = u, w.value.find((e => e.query === n))) {
          const e = w.value.filter((e => e.query === n));
          g.value = e[0].data
        } else {
          const e = await t.requestApi("/user_travels", {
            keywords: u,
            page: 1
          });
          w.value.push({
            query: n,
            data: e.data,
            page: 1
          });
          const a = w.value.filter((e => e.query === n));
          g.value = a[0].data
        }
        console.log(w.value), x.value = w.value.findIndex((e => e.query === n))
      }
      e.onLoad((async () => {
        const a = await t.requestApi("/wxGainDailyRecom", {
          page: 1
        });
        i.value = a.data.data[0], c.value = a.data.count;
        const n = await t.requestApi("/wxGainRecomTravel");
        console.log(n), f.value = n.data;
        const u = await t.requestApi("/recomm_travel"),
          s = await t.requestApi("/travelogue_class"),
          r = await t.requestApi("/user_travels", {
            keywords: "001",
            page: 1
          });
        console.log(r), d.value = u.data, p.value = s.data, w.value.push({
          query: 0,
          data: r.data,
          page: 1
        }), g.value = w.value[0].data, await e.nextTick$1(), e.index.createSelectorQuery().selectAll(".tab").boundingClientRect((e => {
          m.value = e.map(((e, a) => ({
            width: e.width,
            left: e.left
          })))
        })).exec()
      }));
      const b = e.ref(1);
      e.onPullDownRefresh((async () => {
        b.value++, b.value >= c.value + 1 && (b.value = 1);
        const a = await t.requestApi("/wxGainDailyRecom", {
          page: b.value
        });
        i.value = a.data.data[0], e.wx$1.stopPullDownRefresh()
      })), e.onReachBottom((async () => {
        w.value[x.value].page++;
        const e = await t.requestApi("/user_travels", {
          keywords: _.value,
          page: w.value[x.value].page
        });
        w.value[x.value].data = [...w.value[x.value].data, ...e.data], g.value = w.value[x.value].data
      }));
      const T = e.ref(0);

      function $() {
        l(), e.wx$1.switchTab({
          url: "/pages/found/found"
        })
      }

      function A() {
        e.wx$1.navigateTo({
          url: "/pages/search-travel/search"
        })
      }

      function V(a, t) {
        0 === a ? e.wx$1.navigateTo({
          url: "/pages/companion/companion"
        }) : 2 === a || e.wx$1.navigateTo({
          url: `/pages/types-travel/index?type=001&query=${t}&address=null`
        })
      }
      return e.onPageScroll((e => {
        e.scrollTop <= 200 ? T.value = 0 : T.value = e.scrollTop / 140
      })), (a, t) => e.e({
        a: e.o(A),
        b: e.s(a.__cssVars()),
        c: e.n(e.unref(r) ? "add-Image-hei" : "breathe"),
        d: i.value.imageUrl,
        e: e.o(o),
        f: e.unref(r) ? 1 : "",
        g: !e.unref(r)
      }, (e.unref(r), {}), {
        h: !e.unref(r)
      }, e.unref(r) ? {} : {
        i: e.o(o)
      }, {
        j: !e.unref(r)
      }, e.unref(r) ? {} : {
        k: e.o($)
      }, {
        l: !e.unref(r)
      }, e.unref(r) ? {} : {
        m: i.value.color,
        n: e.o(A)
      }, {
        o: e.f(v.value, ((a, t, n) => ({
          a: a.icon,
          b: e.t(a.text),
          c: t,
          d: e.o((e => V(t, a.text)), t)
        }))),
        p: !e.unref(r),
        q: e.unref(r)
      }, e.unref(r) ? {
        r: e.t(i.value.title),
        s: e.t(i.value.address),
        t: e.o((a => {
          return t = i.value.address, l(), s.$patch({
            address: t
          }), void e.wx$1.switchTab({
            url: "/pages/found/found"
          });
          var t
        })),
        v: e.o($)
      } : {}, {
        w: e.o(l),
        x: e.unref(r),
        y: e.unref(r) ? 1 : "",
        z: e.s(a.__cssVars()),
        A: e.s(a.__cssVars()),
        B: e.f(d.value, ((a, t, n) => ({
          a: a.icon,
          b: e.t(a.text),
          c: t,
          d: e.o((e => V(-1, a.text)), t)
        }))),
        C: e.s(a.__cssVars()),
        D: e.f(p.value, ((a, t, n) => ({
          a: e.t(a.name),
          b: y.value === t ? 1 : "",
          c: y.value === t ? 1 : "",
          d: t,
          e: t,
          f: e.o(q, t)
        }))),
        E: h.value,
        F: e.s(a.__cssVars()),
        G: "001" == _.value,
        H: e.s(a.__cssVars()),
        I: e.p({
          newestTravel: f.value
        }),
        J: e.s(a.__cssVars()),
        K: e.p({
          userTravels: g.value
        }),
        L: e.s(a.__cssVars())
      })
    },
    __runtimeHooks: 1
  };
wx.createPage(r);